package demo1230.homework;


public class Baozidian extends Thread{
    private Baozi baoZi;
    public Baozidian(Baozi baoZi){
        this.baoZi=baoZi;
    }
    @Override
    public void run(){
        int count=0;
        while (true){
            synchronized (baoZi){
                if(baoZi.isZhtai()){
                    try {
                        baoZi.wait();
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
                System.out.println("老板开始做包子");
                if(count%3==0){
                    baoZi.setPi("薄皮");
                    baoZi.setXian("牛肉粉丝");
                }else if(count%3==1){
                    baoZi.setPi("薄皮");
                    baoZi.setXian("香菇青菜");
                }else if(count%3==2){
                    baoZi.setPi("薄皮");
                    baoZi.setXian("鸡蛋");
                }
                count++;
                baoZi.setZhtai(true);
                baoZi.notify();
            }
        }
    }
}
